from time import sleep
from selenium import webdriver

driver = webdriver.Firefox()
driver.get('https://www.baidu.com/')
sleep(1)
driver.find_element_by_id('kw').send_keys('网易邮箱')
driver.find_element_by_id('su').click()
sleep(1)
driver.find_element_by_partial_link_text('163网易免费邮').click()
sleep(2)
has = driver.window_handles
driver.switch_to.window(has[1])

iframe = driver.find_elements_by_tag_name('iframe')
driver.switch_to.frame(iframe[0])
driver.find_element_by_name('email').send_keys('liuyibo_cc')
driver.find_element_by_name('password').send_keys('wurenkeji')
driver.find_element_by_id('dologin').click()
sleep(2)

driver.switch_to.default_content()
xx_xpath = '//*[@id="_mail_component_24_24"]'
driver.find_element_by_xpath(xx_xpath).click()
sleep(2)
sjr_xpath = '//input[@class="nui-editableAddr-ipt"]'
driver.find_element_by_xpath(sjr_xpath).send_keys('ma_linpop@163.com')
zt_xpath = "//*[contains(@id, 'subjectInput')]"
driver.find_element_by_xpath(zt_xpath).send_keys('化工学院_科171_刘义博')
driver.switch_to.frame(driver.find_element_by_class_name("APP-editor-iframe"))
nr_xpath = '/html/body'
driver.find_element_by_xpath(nr_xpath).send_keys('吃葡萄不吐葡萄皮！！！')
driver.switch_to.default_content()
fs_xpath = '/html/body/div[2]/div[1]/div[2]/header/div/div[1]/div/span[2]'
driver.find_element_by_xpath(fs_xpath).click()